/* eslint-disable */
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';

// 工序数据类型
export type ProcessItem = {
    createBy?: string | null;
    createTime?: string | null;
    updateBy?: string | null;
    updateTime?: string | null;
    remark?: string | null;
    processId: string;
    processName: string;
    processRemarks?: string | null;
    dataStatus: number;
};

// 工序列表响应类型
export type ProcessListResponse = {
    total: number;
    rows: ProcessItem[];
    code: number;
    msg: string;
};

// 新增工序步骤请求类型
export type CreateProcessStepRequest = {
    processCardId: string;      // 流程卡ID
    processId: string;          // 工序ID
    productionType: string;     // 生产类型/批次号
    productionLength: number;   // 生产长度
    productionTime: string;     // 生产时间（ISO格式）
    staffId: number;           // 员工ID
};

// 新增工序步骤响应类型
export type CreateProcessStepResponse = {
    code: number;
    msg: string;
    data?: any;
};

// 工序步骤记录类型
export type ProcessStepRecord = {
    id?: string;
    processCardId: string;
    processId: string;
    productionType: string;
    productionLength: number;
    productionTime: string;
    staffId: number;
    jointsCount?: number; // 接头数
    description?: string; // 说明
    smallRollModel?: string; // 小卷型号
    smallRollSpecification?: string; // 小卷规格
    createTime?: string;
    updateTime?: string;
};

// 获取工序步骤记录响应类型
export type GetProcessStepResponse = {
    code: number;
    msg: string;
    data?: ProcessStepRecord[];
};

// 批次号查询流程卡响应类型
export type BatchToProcessCardResponse = {
    code: number;
    msg: string;
    data?: string; // 流程卡号
};

// 流程卡详细信息类型
export type ProcessCardDetail = {
    createBy?: string | null;
    createTime?: string | null;
    updateBy?: string | null;
    updateTime?: string | null;
    remark?: string | null;
    id: string;
    createDate: string;
    batchNumber: string;
    productionSpecId: string;
    productionSpecName: string;
    filmSupplierSpec: string;
    description: string;
    currentProcessId: string;
    currentProcessName: string;
    remainingLength: number;
    lossLength: number;
    abnormalCount: number;
    staffId: string;
    staffName: string;
    dataStatus: number;
};

// 流程卡详细信息响应类型
export type ProcessCardDetailResponse = {
    msg: string;
    code: number;
    data?: ProcessCardDetail;
};

// 工序异常记录类型
export type ProcessStepException = {
    id?: string;
    processCardId: string;
    processStepId: string;
    exceptionName: string;
    exceptionTime?: string;
    createTime?: string;
    updateTime?: string;
};

// 获取工序异常响应类型
export type GetProcessStepExceptionResponse = {
    code: number;
    msg: string;
    data?: ProcessStepException[];
};

// 小卷规格类型
export type SmallRollSpec = {
    createBy?: string | null;
    createTime?: string | null;
    updateBy?: string | null;
    updateTime?: string | null;
    remark?: string | null;
    smallRollId: string;
    model: string;
    specification: string;
    purpose: string;
    dataStatus: number;
};

// 小卷规格列表响应类型
export type SmallRollSpecListResponse = {
    total: number;
    rows: SmallRollSpec[];
    code: number;
    msg: string;
};

// 工序步骤异常请求类型
export type ProcessStepExceptionRequest = {
    processCardId: string;
    exceptionId: string;
};

// 新增工序步骤请求类型
export type AddProcessStepRequest = {
    processCardId: string;
    processId: string;
    productionType?: string; // 生产类型，可选
    productionLength: string;
    productionTime: string;
    jointsCount?: number; // 接头数
    description?: string; // 说明
    smallRollId?: string; // 小卷规格ID
    processStepException?: ProcessStepExceptionRequest[];
};

// 修改工序步骤请求类型
export type EditProcessStepRequest = {
    id: string;
    processCardId: string;
    processId: string;
    productionType?: string; // 生产类型，可选
    productionLength: string;
    productionTime: string;
    jointsCount?: number; // 接头数
    description?: string; // 说明
    smallRollId?: string; // 小卷规格ID
    processStepException?: ProcessStepExceptionRequest[];
};

// 工序步骤操作响应类型
export type ProcessStepOperationResponse = {
    code: number;
    msg: string;
    data?: any;
};

// 仓库数据类型
export type WarehouseItem = {
    createBy?: string | null;
    createTime?: string | null;
    updateBy?: string | null;
    updateTime?: string | null;
    remark?: string | null;
    id: string;
    warehouseName: string;
    creatorid?: number;
    creatorName?: string;
    managerid?: number;
    managerName?: string;
    description?: string;
    dataStatus: number;
    warehouseType: string;
};

// 仓库列表响应类型
export type WarehouseListResponse = {
    total: number;
    rows: WarehouseItem[];
    code: number;
    msg: string;
};

// 库存汇总数据类型
export type InventorySummaryItem = {
    createBy?: string | null;
    createTime?: string | null;
    updateBy?: string | null;
    updateTime?: string | null;
    remark?: string | null;
    smallRollId: string;
    model: string;
    specification: string;
    warehouseId: string;
    warehouseName: string;
    quantity: number;
};

// 库存汇总列表响应类型
export type InventorySummaryListResponse = {
    total: number;
    rows: InventorySummaryItem[];
    code: number;
    msg: string;
};

export class ProcessService {
    /**
     * 获取工序列表
     * @param pageNum 页码
     * @param pageSize 页面大小
     * @returns ProcessListResponse 工序列表响应
     * @throws ApiError
     */
    public static getProcessList(
        pageNum: number = 1,
        pageSize: number = 10,
    ): CancelablePromise<ProcessListResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/process/list',
            query: {
                'pageNum': pageNum,
                'pageSize': pageSize,
            },
        });
    }

    /**
     * 新增工序步骤
     * @param requestBody 新增工序步骤请求数据
     * @returns CreateProcessStepResponse 新增工序步骤响应
     * @throws ApiError
     */
    public static createProcessStep(
        requestBody: CreateProcessStepRequest,
    ): CancelablePromise<CreateProcessStepResponse> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/produce/processstep',
            body: requestBody,
        });
    }

    /**
     * 根据流程卡ID和工序ID获取工序记录
     * @param processCardId 流程卡ID
     * @param processId 工序ID
     * @returns GetProcessStepResponse 工序记录响应
     * @throws ApiError
     */
    public static getProcessStepByIds(
        processCardId: string,
        processId: string,
    ): CancelablePromise<GetProcessStepResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/processstep/getByProcessCardIdAndProcessId',
            query: {
                'processCardId': processCardId,
                'processId': processId,
            },
        });
    }

    /**
     * 根据批次号查询流程卡号
     * @param batchNumber 批次号
     * @returns BatchToProcessCardResponse 流程卡号响应
     * @throws ApiError
     */
    public static getProcessCardByBatch(
        batchNumber: string,
    ): CancelablePromise<BatchToProcessCardResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/processcard/batch/{batchNumber}',
            path: {
                'batchNumber': batchNumber,
            },
        });
    }

    /**
     * 根据批次号获取流程卡详细信息
     * @param batchNumber 批次号
     * @returns ProcessCardDetailResponse 流程卡详细信息响应
     * @throws ApiError
     */
    public static getProcessCardDetailByBatch(
        batchNumber: string,
    ): CancelablePromise<ProcessCardDetailResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/processcard/batch/{batchNumber}',
            path: {
                'batchNumber': batchNumber,
            },
        });
    }

    /**
     * 根据流程卡ID和工序记录ID获取工序异常
     * @param processCardId 流程卡ID
     * @param processStepId 工序记录ID
     * @returns GetProcessStepExceptionResponse 工序异常响应
     * @throws ApiError
     */
    public static getProcessStepExceptions(
        processCardId: string,
        processStepId: string,
    ): CancelablePromise<GetProcessStepExceptionResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/processstepexception/getByProcessCardIdAndProcessStepId',
            query: {
                'processCardId': processCardId,
                'processStepId': processStepId,
            },
        });
    }

    /**
     * 获取小卷规格列表
     * @returns SmallRollSpecListResponse 小卷规格列表响应
     * @throws ApiError
     */
    public static getSmallRollSpecList(): CancelablePromise<SmallRollSpecListResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/smallrollspec/list',
        });
    }

    /**
     * 新增工序步骤
     * @param requestBody 新增工序步骤请求数据
     * @returns ProcessStepOperationResponse 操作响应
     * @throws ApiError
     */
    public static addProcessStep(
        requestBody: AddProcessStepRequest,
    ): CancelablePromise<ProcessStepOperationResponse> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/produce/processstep/add',
            body: requestBody,
        });
    }

    /**
     * 修改工序步骤
     * @param requestBody 修改工序步骤请求数据
     * @returns ProcessStepOperationResponse 操作响应
     * @throws ApiError
     */
    public static editProcessStep(
        requestBody: EditProcessStepRequest,
    ): CancelablePromise<ProcessStepOperationResponse> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/produce/processstep/edit',
            body: requestBody,
        });
    }

    /**
     * 获取仓库列表
     * @returns WarehouseListResponse 仓库列表响应
     * @throws ApiError
     */
    public static getWarehouseList(): CancelablePromise<WarehouseListResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/warehouse/list',
        });
    }

    /**
     * 保存成品登记
     * @param requestBody 成品登记请求数据
     * @returns any 操作响应
     * @throws ApiError
     */
    public static saveFinishedProduct(
        requestBody: {
            processCardId: string;      // 流程卡ID
            smallRollSpecId: string;    // 小卷规格ID  
            warehouseId: string;        // 仓库ID
            quantity: string;           // 数量
            direction: string;          // 方向（入库/出库）
        },
    ): CancelablePromise<any> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/produce/finishedproduct',
            body: requestBody,
        });
    }

    /**
     * 查询成品登记列表
     * @param queryParams 查询参数
     * @returns any 查询响应
     * @throws ApiError
     */
    public static getFinishedProductList(
        queryParams?: {
            processCardId?: string;     // 流程卡ID
            smallRollSpecId?: string;   // 小卷规格ID
            direction?: string;         // 方向（入库/出库）
        },
    ): CancelablePromise<any> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/finishedproduct/list',
            query: queryParams,
        });
    }

    /**
     * 出库操作
     * @param requestBody 出库请求数据
     * @returns any 操作响应
     * @throws ApiError
     */
    public static outbound(
        requestBody: {
            smallRollId: string;    // 小卷ID
            warehouseId: string;    // 仓库ID
            quantity: number;       // 数量
            remarks: string;        // 说明
        },
    ): CancelablePromise<any> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/produce/outbound',
            body: requestBody,
        });
    }

    /**
     * 查询出库列表
     * @param queryParams 查询参数
     * @returns any 查询响应
     * @throws ApiError
     */
    public static getOutboundList(
        queryParams?: {
            pageNum?: number;       // 页码
            pageSize?: number;      // 每页条数
            smallRollId?: string;   // 小卷ID
        },
    ): CancelablePromise<any> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/outbound/list',
            query: queryParams,
        });
    }

    /**
     * 查询库存汇总列表
     * @param queryParams 查询参数
     * @returns InventorySummaryListResponse 库存汇总列表响应
     * @throws ApiError
     */
    public static getInventorySummaryList(
        queryParams?: {
            pageNum?: number;       // 页码
            pageSize?: number;      // 每页条数
            smallRollId?: string;   // 小卷规格ID
            warehouseId?: string;   // 仓库ID
        },
    ): CancelablePromise<InventorySummaryListResponse> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/produce/smallrollinventorysummary/list',
            query: queryParams,
        });
    }
}
